package jianxinjinke;

import java.util.Arrays;
import java.util.HashMap;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/11/24-下午11:32
 * Since  :   1.0
 * Version:   1.0
 */


public class test {

    public static int[] twoSum(int[] nums, int target) {


        int[] results = new int[2];
//        HashMap<Integer, Integer> map = new HashMap<>();
//        int k = 0;
//        for (int i : nums) {
//            if (map.containsKey(target - i)) {
//                results[0] = k;
//                results[1] = map.get(target - i);
//                return results;
//            }
//            map.put(i, k);
//
//
//            k++;
//        }
        HashMap<Integer, Integer> map = new HashMap<>();
        int index=0;
        for(int i:nums){
            if (map.containsValue(target-i)){
                results[0] = index;
                results[1] = index;
            }

            map.put(index,i);
            index++;
        }




        return results;
    }

    public static void main(String[] args) {
        int nums[] = {3, 3};
        int target = 6;
        int[] ints = twoSum(nums, target);
        System.out.println(Arrays.toString(ints));
    }
}
